package com.xjc.market.acct.service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import com.xjc.infra.base.BaseService;
import com.xjc.infra.entity.ExecuteState;
import com.xjc.infra.entity.MiniDataGridParams;
import com.xjc.infra.entity.QueryResult;
import com.xjc.infra.entity.SessionContext;
import com.xjc.infra.util.PageFrom;
import com.xjc.market.acct.biz.AcOperatorBiz;
import com.xjc.market.acct.entity.table.AcOperator;
import com.xjc.market.frame.util.FrameUtil;

/**
 * 操作员-服务
 * @author liangcz
 * @Date   2017年9月5日 下午5:26:09
 * @version 1.0
 */
@RestController
@RequestMapping("/acct/service/AcOperatorService")
public class AcOperatorService extends BaseService{
	Logger logger = Logger.getLogger(this.getClass());
	@Autowired
	AcOperatorBiz acOperatorBiz;
	/**
	 * 跳转操作员界面
	 * @author liangcz
	 * @date   2017年9月6日 上午11:12:52
	 * @return void
	 */
	@RequestMapping("/goAcOperator")
	public ModelAndView goAcOperator(SessionContext sessionContext,HttpServletRequest request, HttpServletResponse response){
		logger.info("跳转操作员界面开始");
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName(PageFrom.getView("acct", "acOperator"));
		logger.info("跳转操作员界面结束");
		return modelAndView;
	}	
	/**
	 * 查询指定操作员信息
	 * @author liangcz
	 * @date   2017年9月21日 下午4:16:47
	 * @return void
	 */
	@RequestMapping("/inquiryAcOperator")
	public void inquiryAcOperator(SessionContext sessionContext,HttpServletRequest request,HttpServletResponse response,
			AcOperator acOperator){
		logger.info("查询指定操作员信息");
		AcOperator acOperator1 = acOperatorBiz.selectOne(acOperator);
		PageFrom.jsonResponseWriter(acOperator1, response);
		logger.info("查询指定操作员信息");
	}
	/**
	 * 查询操作员列表
	 * @author liangcz
	 * @date   2017年9月15日 下午5:50:37
	 * @return void
	 */
	@RequestMapping("/inquiryAcOperatorList")
	public void inquiryAcOperatorList(SessionContext sessionContext,HttpServletRequest request,HttpServletResponse response,
			AcOperator acOperator,MiniDataGridParams miniDataGridParams){
		logger.info("查询操作员列表开始");
		// QueryResult queryResult = acOperatorBiz.select(acOperator, miniDataGridParams.getPager());
		QueryResult queryResult = acOperatorBiz.inquiryAcOperatorList(acOperator, miniDataGridParams.getPager());
		PageFrom.jsonResponseWriter(queryResult, response);
		logger.info("查询操作员列表结束");
	}
	/**
	 * 操作员新增/编辑
	 * @author liangcz
	 * @date   2017年9月21日 下午2:56:48
	 * @return void
	 */
	@ResponseBody
	@RequestMapping("/goAcOperatorWindow")
	public ModelAndView goAcOperatorWindow(SessionContext sessionContext,HttpServletRequest request,HttpServletResponse response,AcOperator acOpearator){
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName(PageFrom.getView("acct", "acOperatorWindow"));
		return modelAndView;
	}
	/**
	 * 保存操作员信息
	 * @author liangcz
	 * @date   2017年9月21日 下午2:56:48
	 * @return void
	 */
	@ResponseBody
	@RequestMapping("/saveAcOperator")
	public ExecuteState saveAcOperator(SessionContext sessionContext,HttpServletRequest request,HttpServletResponse response,AcOperator acOpearator){
		// ExecuteState state = acOperatorBiz.saveAcOperator(sessionContext,acOpearator);
		acOperatorBiz.saveAcOperator(sessionContext,acOpearator);
		return FrameUtil.getSuccessExcuteState();
		// PageFrom.jsonResponseWriter(state, response);
	}
	/**
	 * 删除操作员信息
	 * @param operatorIds 操作员id，以逗号隔开。 如： 1,2,3
	 * @author liangcz
	 * @date   2017年9月21日 下午2:56:48
	 * @return void
	 */
	@RequestMapping("/deleteAcOperator")
	public ExecuteState deleteAcOperator(SessionContext sessionContext,HttpServletRequest request,HttpServletResponse response,@RequestParam("operatorIds") String operatorIds){
		acOperatorBiz.deleteAcOperator(sessionContext,operatorIds);
		return FrameUtil.getSuccessExcuteState();
		// PageFrom.jsonResponseWriter(state, response);
	}
	
	
	
}
